﻿@model BudgetMealsUI.Models.ListViewModel<BudgetMealsModels.Entities.Meal>

@{
    ViewBag.Title = "All Meals";
}

<link href="@Url.Content("~/Content/CSS/Thumbnails.css")" rel="stylesheet" type="text/css" />

@if (Session["CurrentUser"] != null)
{
    @Html.ActionLink("New Meal", "Edit", new { userID = HttpContext.Current.Session["CurrentUser"] })<br />
}

@foreach (var meal in Model.PageItems)
{
    <div style="width: 100%; display: block; clear: both; position: relative;">
        <h3 style="background-color: rgba(0, 0, 0, .05); border-top-left-radius: 5px; border-top-right-radius: 5px; padding-left: 5px;">@meal.Name</h3>

        <div style="position: absolute; top: 2px; right: 5px;">Costs $@meal.Cost.ToString("N2")</div>

        @{ 
            Html.RenderPartial("AllMealsElement", new AllMealsElementModel { Meal = meal, Recipe = meal.Appetizer, Title = "Appetizer" });
            Html.RenderPartial("AllMealsElement", new AllMealsElementModel { Meal = meal, Recipe = meal.MainCourse, Title = "Main Course" });
            Html.RenderPartial("AllMealsElement", new AllMealsElementModel { Meal = meal, Recipe = meal.Dessert, Title = "Dessert" });
        }

        <div id="RecipeSummary@(meal.MealID)">
            <h4>@meal.Appetizer.Name $@meal.Appetizer.Cost.ToString("N2") (Appetizer)</h4>
            @Html.Raw(meal.Appetizer.Summary)
        </div>
    </div>
}
<div class="ClearFix"></div>
<div id="pager">
    @Html.PageLinks(Model.Info, x => Url.Action("AllMeals", new { page = x }))
</div>